<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
  xmlns:c="livcos.org/ns/cosmos"
  xmlns:f="livcos.org/ns/xslt/function"
  xmlns:h="livcos.org/ns/cosmos/history"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="c f h">
  
  <xsl:import href="../../style/base.xsl"/>
  
  <xsl:param name="map" select="'../data/WebMap'"/>
  <xsl:param name="item">
    <xsl:variable name="newItemId" select="/*/h:changes/h:change/h:insert/@ref[starts-with(., 'item_')][last()]"/>
    <xsl:choose>
      <xsl:when test="$newItemId"><xsl:value-of select="$newItemId"/></xsl:when>
      <xsl:otherwise>item_1</xsl:otherwise>
    </xsl:choose>
  </xsl:param>
  
  <xsl:variable name="uri" select="concat('nav.html?map=', $map, '&amp;item=', $item, '&amp;autoClose=0')"/>
  
  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>LivCos</title>
        <script type="text/javascript">
          <xsl:comment>
            window.location.replace("<xsl:value-of select="$uri"/>");
          </xsl:comment>
        </script>
      </head>
      <body>
        <h1>LivCos</h1>
        <p>
          Redirecting to the <a href="{$uri}">Web Map</a>...
        </p>
        <p style="font-weight: bold; color: red;">
          In order to use the LivCos Web interface you need to enable JavaScript!
        </p>
      </body>
    </html>
  </xsl:template>
  
</xsl:stylesheet>
